#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include <QWidget>
#include <cxcore.h>
#include <highgui.h>
#include "ui_mainwidget.h"

class ImageWidget;

class MainWidget : public QWidget, public Ui::MainWidget
{
    Q_OBJECT
public:
    explicit MainWidget(QWidget *parent = 0);

protected:
    bool eventFilter(QObject *watched, QEvent *event);
    void keyPressEvent(QKeyEvent *event);

private:
    void processMouseDoubleClicked();

signals:
    void updateImage(const IplImage *frame);

public slots:
    void onUpdateSize(const IplImage *frame);

private slots:
    void onLoadVideoButton();
    void onTimeOut();

    void onGetImageAction();
    void onNextFrameAction();
    void onRestartAction();

public:
    ImageWidget *imageWidget;

private:
    QTimer *updateTimer;
    CvCapture *capture;
    QAction *getImageAction;
    QAction *nextFrameAction;
    QAction *restartAction;
    int nextFrame;

    CvPoint startPoint;
    CvPoint endPoint;

    IplImage *backupImage;
    IplImage *drawingImage;

    bool isDrawing;
};

#endif // MAINWIDGET_H
